package site.shihuan.helpdesk.common.amqp.util;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import site.shihuan.helpdesk.common.amqp.config.AmqpExchange;

/**
 * RabbitMQ工具类
 *
 * @author 周世焕
 * @Date 2021/3/12 11:09
 */
@Component
public class AmqpMsgUtil {

    public static RabbitTemplate rabbitTemplate;

    @Autowired
    public void setRabbitTemplate(RabbitTemplate rabbitTemplate) {
        AmqpMsgUtil.rabbitTemplate = rabbitTemplate;
    }

    public static void sendMsg(String exchange,String queue,Object obj) {
        rabbitTemplate.convertAndSend(exchange,queue,obj);
    }
}
